<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>
<%
String id=request.getParameter("id");
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>欢迎访问产品运营互动中心！</title>
<link rel="stylesheet" href="<s:url value="/css/style_new.css"/>">
<script type="text/javascript" src="<s:url value="/script/easyajax.js"/>"></script>
<script>
/*产品目录ID*/
var id="<%=id%>";
if(id==null||id=="null"){
	id="${productRefSort.sort}";
}
/*实例化产品结果集脚本对象*/
var productAjax=new AjaxObj();
var refAjax=new AjaxObj();
function initPage(){
    getRef();
	getProduct();
}
/*查询所有产品*/
function getProduct(){
    for(i=$("productId").options.length-1;i>-1;i--){
    	$("productId").remove(i);
    }
    var url="<s:url value="/business/product/viewProduct.action"/>";
    if(form1["conds.name"].value!=""){
    	url+="?conds.name="+encodeURIComponent(form1["conds.name"].value);
    }
	callSynchronized(url,function(XML){//同步调用
	    productAjax=new AjaxObj();
	    productAjax.xml=XML.responseXML;
	    productAjax.menuId="productId";
	    productAjax.createMenu();
	});
	filterProduct();
}
/*查询当前产品目录下已关联的产品*/
function getRef(){
	callSynchronized("<s:url value="/business/product/viewNextproductRefSort.action"/>?conds.sort="+id,function(XML){//同步调用
	    refAjax=new AjaxObj();
	    refAjax.xml=XML.responseXML;
	    refAjax.menuId="refId";
	    refAjax.createMenu();
	});
}
/*已关联的产品从产品列表中过滤掉*/
function filterProduct(){
	for(i=$("productId").options.length-1;i>-1;i--){
		for(j=0;j<$("refId").options.length;j++){
			if($("productId").options[i].value==$("refId").options[j].value||$("productId").options[i].value==0){
				$("productId").remove(i);
				break;
			}
		}
	}
}
/*新增关联产品*/
function addProduct(){
	for(i=$("productId").options.length-1;i>-1;i--){
		if($("productId").options[i].selected==true){
		    var option=document.createElement("option");
	    	option.value=$("productId").options[i].value;
	    	option.text=$("productId").options[i].text;
			$("refId").add(option);
			$("productId").remove(i);
		}
	}
}
/*新增所有关联产品*/
function addAll(){
    if(!confirm("确定全部增加")){
    	return;
    }
	for(i=$("productId").options.length-1;i>-1;i--){
	    var option=document.createElement("option");
    	option.value=$("productId").options[i].value;
    	option.text=$("productId").options[i].text;
		$("refId").add(option);
		$("productId").remove(i);
	}
}
/*删除关联产品*/
function deleteProduct(){
	for(i=$("refId").options.length-1;i>-1;i--){
		if($("refId").options[i].selected==true){
		    var option=document.createElement("option");
	    	option.value=$("refId").options[i].value;
	    	option.text=$("refId").options[i].text;
			$("productId").add(option);
			$("refId").remove(i);
		}
	}
}
/*删除所有关联产品*/
function deleteAll(){
    if(!confirm("确定全部删除")){
    	return;
    }
	for(i=$("refId").options.length-1;i>-1;i--){
	    var option=document.createElement("option");
    	option.value=$("refId").options[i].value;
    	option.text=$("refId").options[i].text;
		$("productId").add(option);
		$("refId").remove(i);
	}
}
/*保存提交*/
function save(){
	var str="";
	for(i=$("refId").options.length-1;i>-1;i--){
    	str+=$("refId").options[i].value+",";
	}
	str=str.substring(0,str.length-1);
	form1.refIds.value=str;
	form1.submit();
}
</script>
<script type="text/javascript" src="<s:url value="/script/selfResize.js"/>"></script>
<script>
function initLoad(){
	f_iframeResize();
}
function initData(){
	initPage();
	initLoad();
}
window.onload = initData;
window.setInterval("initLoad()", 200);
</script>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<table width="980" border="0" cellspacing="0" cellpadding="0"
	align="center">
	<tr>
		<td>
		<table width="100%" border="0" cellpadding="0" cellspacing="0"
			background="<s:url value="/images/new/gxzl_index_2.gif"/>">
			<tr>
				<td width="20" height="32">&nbsp;</td>
				<td width="20"><img
					src="<s:url value="/images/new/dq_dot.gif"/>" width="15"
					height="12" /></td>
				<td>当前位置：<a href="<s:url value="/business/catalog/listProductSort.action"/>">福建省产品目录维护</a></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td background="<s:url value="/images/home_4a.gif"/>">
		<table width="100%" height="" border="0" cellspacing="0"
			cellpadding="0" align="center" bgcolor="#FFFFFF">
			<tr>
				<td width="240" valign="top" class="leftbg">
				<%@ include
					file="/commons/include/catalog_left.inc"%>
				</td>
				<td valign="top" align="center">
				<br>
				<s:form id="form1"
					action="/business/product/saveproductRefSort.action" method="post">
					<input type="hidden" name="refIds">
					<input type="hidden" name="productRefSort.sort" value="">
					<table width="660" border="0" cellspacing="0" cellpadding="0"
						background="<s:url value="/images/catalog_manage_8b.gif"/>">
						<tr>
							<td><img src="<s:url value="/images/catalog_manage_8.gif"/>"
								width=660 height=11 alt=""></td>
						</tr>
						<tr>
							<td>
							<TABLE width="100%" border="0" cellspacing="0" cellpadding="0"
								align="center" class=tablecolor2>
								<tr>
									<td width="15%" height="50">
									<div align="center"><a href="shareinfo.html"
										target="_blank">产品名称</a></div>
									</td>
									<td width="35%"><input name="conds.name" type="text"
										value="${conds.name}" size="30" /></td>
									<td><input type="button" name="search"
										onclick="getProduct();" value="查 询">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="button" name="search" onclick="save()" value="保 存">
									</td>
								</tr>
							</TABLE>
							<table border="0" width="100%">
								<tr>
									<td colspan="3">&nbsp;<font color="red">${returnMsg}</font></td>
								</tr>
								<tr>
									<td valign="top">全部产品 <select name="productId"
										id="productId" style="width: 280px; height: 400px"
										property="id" labelProperty="name" multiple="multiple">
									</select></td>
									<td aling="center" width="20" valign="middle"><input
										type="button" value="增加产品" onclick="addProduct()"> <br>
									<input type="button" value="增加全部" onclick="addAll()"> <br>
									<input type="button" value="删除产品" onclick="deleteProduct()">
									<br>
									<input type="button" value="删除全部" onclick="deleteAll()">
									</td>
									<td aling="center" valign="top">已选产品 <select name="refId"
										id="refId" style="width: 280px; height: 400px"
										property="product" labelProperty="productName"
										multiple="multiple">
									</select></td>
								</tr>
							</table>
							</td>
						</tr>
					</table>
				</s:form></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</body>
</html>
<script>
form1["productRefSort.sort"].value=id;
var obj1=document.getElementById("iTR3");
if(obj1){
	obj1.style.backgroundColor="B3DEF4";
}
</script>